﻿@model Forest.Cat.Admin.Models.JobHunting.JobAlertListModel
@using Forest.Cat.Admin.Extensions;
@{
    ViewBag.Title = "职位搜索器";
    Layout = "~/Administration/Views/Shared/_AdminLayout.cshtml";
}
<div class="savedsearch_manage_right">
    <div class="savedsearch_manage_right_title">
        @ViewBag.Title</div>
    <div class="savedsearch_manage_right_box">
        <p>
            <b>您已经创建了 @Model.SearchCount 个职位搜索</b><span>（最多可订阅10个）</span>
            @if (Model.SearchCount < 10)
            { <a href="@Url.Action("SavedSearchAdd")"><img alt="" src="/Themes/DarkOrange/Content/images/img-builtSearch-86-19.jpg" /></a>
            }</p>
        <table cellpadding="0" cellspacing="0" class="rebook_tab" width="100%">
            <tr>
                <th>
                    <input type="checkbox" class="checkboxHeader" />
                </th>
                <th>
                    订阅日期
                </th>
                <th>
                    搜索名称
                </th>
                <th>
                    最近修改
                </th>
                @*                <th>
                    邮件发送
                </th>*@
                <th>
                    操作
                </th>
            </tr>
            @foreach (var mode in Model.JobAlertList)
            { 
                <tr id="@mode.Id">
                    <td style="text-align: center;">
                        <input type="checkbox" class="checkboxItem" />
                    </td>
                    <td style="text-align: center;">
                        @if (mode.DateCreated.HasValue)
                        { @mode.DateCreated.Value.ToString("yyyy-MM-dd")
                        }
                    </td>
                    <td>
                        @mode.Name
                    </td>
                    <td style="text-align: center;">
                        @if (mode.LastUpdated.HasValue)
                        { @mode.LastUpdated.Value.ToString("yyyy-MM-dd") }
                    </td>
                    @*                    <td style="text-align: center;">
                        @mode.FrequencyName
                    </td>*@
                    <td style="text-align: center;">
                        @using (Html.BeginForm("SavedSearchDelete", "JobHunting", FormMethod.Post))
                        {
                            @Html.ActionLink("修改", "SavedSearchEdit", "JobHunting", new { id = mode.Id }, null)  @:|
                            @Html.Hidden("deleteId", mode.Id.ToString())
                            <input type="submit" value="删除" onclick="return confirm('确定删除？');" />
                            @:|
                            @Html.ActionLink("搜索", "", "", new { }, null)
                        }
                    </td>
                </tr>
            }
        </table>
        <div class="pages">
            <p>
                <a href="#">
                    @Html.Pager(Model.PagingFilteringContext).QueryParam("pagenumber")
                </a>
            </p>
            @using (Html.BeginForm("SavedSearchDeleteList", "JobHunting", FormMethod.Post))
            {
                @Html.Hidden("deleteIdList", "")
                <input type="submit" value="删除所选记录" onclick="return GetSelectCheckBox();" />
            }
        </div>
    </div>
</div>
<script type="text/javascript" language="javascript">
    $(window).bind('load', function () {
        var cbHeader = $(".checkboxHeader");
        var cbRowItem = $(".checkboxItem");
        cbHeader.bind("click", function () {
            cbRowItem.each(function () { this.checked = cbHeader[0].checked; })
        });
        cbRowItem.bind("click", function () { if ($(this).checked == false) cbHeader[0].checked = false; });
    });

    function GetSelectCheckBox() {
        var ckList = $(".checkboxItem");
        var cknum = 0;
        var idList = new Array();
        ckList.each(function () {
            if (this.checked) {
                var id = $(this).parent().parent().attr("id");
                idList[cknum] = id;
                cknum = cknum + 1;
            }
        });

        if (cknum == 0) {
            alert("请至少选择一个checkbox");
            return false;
        }

        $("#deleteIdList").val(idList);
        return confirm("确定删除？");
    }
</script>
